/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.bs.user.Authentication;

/**
 *
 * @author RdX
 */
public class AuthController extends HttpServlet {

     protected void doPost(HttpServletRequest request, HttpServletResponse response)
           throws ServletException, IOException {
     // TODO Auto-generated method stu
		String dest=null;
			String login=request.getParameter("login");
			String pass=request.getParameter("pass");
                        //response.getWriter().write(login+" "+pass);
			switch(Authentication.validateLogin(login, pass))
                        {
                           case 1:
                              dest="StudentHome.jsp";
                              break;
                           case 2:
                              dest="EmpHome.jsp";
                              break;
                           case 3:
                              dest="AdminHome.jsp";
                                      break;
                           case 0:
                              dest="Failure.jsp";
                        }
		
		RequestDispatcher rd=request.getRequestDispatcher(dest);
		rd.forward(request,response);
	}
  

  }
